package com.test.springboot3.springboot3testdemo1.entity;

import java.time.LocalDateTime;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.ConstructorBinding;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/7/19-下午4:50
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Data
@NoArgsConstructor
@ConfigurationProperties(prefix = "member")
public class MemberProperties {
  private String name;
  private int sex;
  private int age;
  private String country;
  private LocalDateTime birthday;

  public MemberProperties(String name, int sex, int age) {
    this.name = name;
    this.sex = sex;
    this.age = age;
  }

  @ConstructorBinding
  public MemberProperties(
      String name,
      int sex,
      int age,
      @DefaultValue("China") String country,
      @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime birthday) {
    this.name = name;
    this.sex = sex;
    this.age = age;
    this.country = country;
    this.birthday = birthday;
  }
}
